<?php

namespace fast;

use EasyWeChat\Foundation\Application;
use Doctrine\Common\Cache\RedisCache;
use think\cache\driver\Redis;

class WeChat
{

    protected $options = null;

    public function __construct()
    {
        $cacheDriver = new RedisCache();
        $redis = new Redis();
        $cacheDriver->setRedis($redis->handler());
        $this->options = [
            'debug' => true,
            'app_id' => 'wx54485e0e5e767f14',
            'secret' => '78768dfbf88788a93030265ca32454c7',
            'token' => 'EGi3lExrP36lbr1d7p4m',
            'aes_key' => 'IKDwkYqUFVNUGFqpEFDgYwEyhuGcGxRohuLssbnYXaS',
            'log' => [
                'level' => 'debug',
                //'permission' => 0777,
                'file' => RUNTIME_PATH . 'log/EasyWeChat/' . date('Y-m-d') . '/easywechat.log',
            ],
            'cache' => $cacheDriver,
            /**
             * OAuth 配置
             *
             * scopes：公众平台（snsapi_userinfo / snsapi_base），开放平台：snsapi_login
             * callback：OAuth授权完成后的回调页地址
             */
            'oauth' => [
                'scopes' => ['snsapi_userinfo'],
                'callback' => '/index/index/index',
            ],
        ];
    }

    public function getApp()
    {
        return new Application($this->options);
    }

}
